package kandl.automation.steprunner.selenium.commands;


import kandl.automation.steprunner.selenium.Command;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;

@Component
class GetVerifyText implements Command {
    @Override
    public void runCommand(WebDriver driver, String... params) throws Exception {
        WebElement webElement = driver.findElement(By.xpath(params[0]));
        String text1 = webElement.getText();
        webElement.click();

        WebElement webElement1 = driver.findElement(By.xpath(params[1]));
        String text2 = webElement1.getText();
        if (!text1.equals(text2)){
            throw new VerificationFailedException(text1 +" and "+ text2 +" are not equal.");
        }
    }

    @Override
    public String getName() {
        return "Get_Verify_Text";
    }
}